# frozen_string_literal: true

CONFIG_FILES = %w[
  app/validators/json_schemas/build_metadata_id_tokens.json
  app/validators/json_schemas/build_metadata_config_options.json
  app/validators/json_schemas/build_metadata_secrets.json
  app/validators/json_schemas/ci_job_definition_config.json
  app/validators/json_schemas/run_steps.json
].freeze

def format_file_path(path)
  "`#{path}`"
end

# Check if any schema has changed
changes = helper.all_changed_files & CONFIG_FILES

if changes.any?
  message = <<~MSG
    ## 🚨 Critical: CI JSON Schema Modified

    ### ⚠️ **IMPORTANT NOTICE**

    We are actively working on [reducing the growth rate of ci_builds_metadata partitions](https://gitlab.com/groups/gitlab-org/-/epics/13886).

    Our goal is to reduce the high growth rate of `ci_builds_metadata` by:
    - Deduplicating data
    - Splitting between processing data and intrinsic data

    This merge request modifies CI JSON schema validations which directly impacts this table's growth.

    ### 🔴 What NOT to do:
    - Do not add new properties or validation rules to CI JSON schema files related to `Ci::JobDefinition` & `Ci::BuildMetadata`
    - Do not add complex nested structures
    - Do not store data that could be normalized elsewhere

    ### ✅ What's acceptable:
    - Bug fixes that don't add new fields
    - Removing unused fields

    ### 💡 Recommendations:
    - Consider if this data truly needs to be in `ci_builds_metadata`
    - Explore alternative storage solutions for non-critical config data

    ### 💬 Questions?
    If you have any questions, please ask in `#g_ci-platform`.

    ---

    **CI Platform Team Review Required**: Please tag `@gitlab-com/ci-platform-group` for review of these changes.
  MSG

  warn(message)
end
